﻿using System;
using UnityEngine;
using UnityEngine.UI;

public class UserInfoWidget : MonoBehaviour
{
    public Text nameText;
    public Text idVerifyText;
    public Image idVerifyBg;
    public Text statusText;
    public Text birthYearText;
    public Text xingzuoText;
    public Text heightText;
    public Text weightText;
    public Text locationText;
    public Text hometownText;
    public Text eduText;
    public Text schoolText;
    public Text jobText;
    public Text companyText;


    public Color verifyActiveColor;
    public Color verifyDisactiveColor;
    public void Init(UserInfo userInfo)
    {
        nameText.text = userInfo.name;
        if (userInfo.realNameVerify)
        {
            idVerifyText.text = "已认证";
            idVerifyBg.color = verifyActiveColor;
        }
        else
        {
            idVerifyText.text = "未认证";
            idVerifyBg.color = verifyDisactiveColor;
        }
        statusText.text = userInfo.status;
        birthYearText.text = $"{userInfo.birthYear}年";
        xingzuoText.text = userInfo.xingzuo;
        heightText.text = userInfo.height+"cm";
        weightText.text = userInfo.weight+"kg";
        locationText.text = userInfo.locationProvince + userInfo.locationCity;
        hometownText.text = userInfo.hometownProvince + (userInfo.hometownCity.Replace("省", "").Replace("市","") + "人");
        eduText.text = DataString.GetEducationString(userInfo.eduation);
        schoolText.text = userInfo.school;
        jobText.text = userInfo.job;
        companyText.text = userInfo.company;

    }

    void OnEnable()
    {
        StartCoroutine(UnityFunctions.AdjustItemsLayout(transform));
    }

    public void OnClickStatus()
    {
        GameDebug.Log("UserInfoWidget->OnClickStatus");
    }

}
